import Vue from 'vue';
import VueRouter from 'vue-router';
import store from './store';
import router from './router';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import 'animate.css';
import NProgress from 'nprogress'; //滚动进度效果
import 'nprogress/nprogress.css';
//import 'default-passive-events';
import '@/assets/css/base.scss';
import App from './App.vue';
import '@/assets/icons/iconfont.css';
import moment from 'moment';
//import { createSignalR } from '@/signalr/signalR';
import Contextmenu from 'vue-contextmenujs';
import Oidc from 'oidc-client'
import BtnDirective from './directives/btndirective';
import { BarChart, LineChart, PieChart, ScatterChart } from 'echarts/charts';
import {
  DataZoomComponent,
  GridComponent,
  LegendComponent,
  MarkLineComponent,
  TitleComponent,
  ToolboxComponent,
  TooltipComponent,
  VisualMapComponent,
} from 'echarts/components';
import { use } from 'echarts/core';
import { CanvasRenderer } from 'echarts/renderers';
import VCharts from 'vue-echarts';
import $http from './utils/apiHelper';
import VueCodemirror from 'vue-codemirror'
import 'codemirror/lib/codemirror.css'
import 'xe-utils'
import VueVirtualScroller from 'vue-virtual-scroller'
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
use([
  DataZoomComponent,
  CanvasRenderer,
  MarkLineComponent,
  PieChart,
  BarChart,
  LineChart,
  ScatterChart,
  VisualMapComponent,
  ToolboxComponent,
  GridComponent,
  TitleComponent,
  TooltipComponent,
  LegendComponent,
]);
ElementUI.Dialog.props.closeOnClickModal.default = false; // 全局修改默认配置，点击空白处不能关闭弹窗
ElementUI.Dialog.props.closeOnPressEscape.default = false; // 全局修改默认配置，按下ESC不能关闭弹窗
const originalPush = VueRouter.prototype.push

// 获取原型对象replace函数
const originalReplace = VueRouter.prototype.replace

// 修改原型对象中的push函数
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

// 修改原型对象中的replace函数
VueRouter.prototype.replace = function replace (location) {
  return originalReplace.call(this, location).catch(err => err)
}
Vue.use(ElementUI, { size: 'small' });
Vue.use(VueRouter);
Vue.use(VueCodemirror
);
Vue.use(Contextmenu);
Vue.use(BtnDirective);
Vue.use(VueVirtualScroller)
Vue.component('v-chart', VCharts);
Vue.prototype.$moment = moment;
Vue.config.productionTip = false;

router.beforeEach((to, from, next) => {
  NProgress.start();
  next();
}); //前置路由守卫
router.afterEach(() => {
  NProgress.done();
});

await store.dispatch("loadSystemConfig");

new Vue({
  router,
  store,
  render: (h) => h(App),
  beforeCreate() {
    Vue.prototype.$bus = this; //全局事件总线
  },
}).$mount('#app');

